package com.qf.dao.impl;

import com.qf.dao.PurdProductsDao;
import com.qf.entity.PurdProducts;
import com.qf.utils.JdbcUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

public class PurdProductsDaoImpl implements PurdProductsDao {

    private QueryRunner queryRunner = new QueryRunner(JdbcUtils.ds);

    @Override
    public int insertProducts(PurdProducts pp) {
        String sql = "insert into t_purd_products values(?,?,?,?)";
        try {
            return queryRunner.update(sql,pp.getName(),pp.getNum(),pp.getAmount(),pp.getUid());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return 0;
    }
}
